package bancosys.tec.rtm.diagnostician;

import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;

import bancosys.tec.rtm.diagnostician.report.DiagnosticianReportGenerator;

/**
 * Diagnostician case que executa varios {@link DiagnosticianCase} na sequencia.
 * 
 * @author Rafael Volpato
 * @date May 12, 2011
 */
public class CompositeDiagnosticianCase implements DiagnosticianCase {

    private final List<DiagnosticianCase> diagnosticiansCase;

    /**
     * Construtor.
     * 
     * @param diagnosticiansCase diagnosticiansCase
     */
    public CompositeDiagnosticianCase(List<DiagnosticianCase> diagnosticiansCase) {
        this.diagnosticiansCase = diagnosticiansCase;
    }

    /**
     * {@inheritDoc}
     */
    public void executeDiagnostician(DiagnosticianReportGenerator reportGenerator, OutputStream outputStream) throws Exception {
        for (DiagnosticianCase diagnosticianCase : this.diagnosticiansCase) {
            diagnosticianCase.executeDiagnostician(reportGenerator, outputStream);
        }
    }

    /**
     * {@inheritDoc}
     */
    public void executeDiagnosticianInDebugMode(DiagnosticianReportGenerator reportGenerator, OutputStream outputStream) throws Exception {
        for (DiagnosticianCase diagnosticianCase : this.diagnosticiansCase) {
            diagnosticianCase.executeDiagnosticianInDebugMode(reportGenerator, outputStream);
        }
    }

    /**
     * {@inheritDoc}
     */
    public List<Diagnostician> getDiagnosticiansListOfSystem() throws Exception {
        List<Diagnostician> diagnosticians = new ArrayList<Diagnostician>();
        for (DiagnosticianCase diagnosticianCase : this.diagnosticiansCase) {
            diagnosticians.addAll(diagnosticianCase.getDiagnosticiansListOfSystem());
        }
        return diagnosticians;
    }

    /**
     * {@inheritDoc}
     */
    public List<Diagnostician> getDiagnosticiansListOfSystemInDebugMode() throws Exception {
        List<Diagnostician> diagnosticians = new ArrayList<Diagnostician>();
        for (DiagnosticianCase diagnosticianCase : this.diagnosticiansCase) {
            diagnosticians.addAll(diagnosticianCase.getDiagnosticiansListOfSystemInDebugMode());
        }
        return diagnosticians;
    }
}
